var e = require('../@babel/runtime/helpers/regeneratorRuntime.js'),
  t = require('../@babel/runtime/helpers/asyncToGenerator.js');
module.exports = Behavior({
  properties: {},
  data: {},
  options: { pureDataPattern: /^_afterLogin/ },
  pageLifetimes: { show: function () {} },
  created: function () {},
  attached: function () {},
  ready: function () {},
  methods: {
    _handBeforeFun: function (n) {
      var a = this;
      return t(
        e().mark(function t() {
          var r, i, o, u;
          return e().wrap(function (e) {
            for (;;)
              switch ((e.prev = e.next)) {
                case 0:
                  return (e.next = 2), a._behavior_judgeLogin();
                case 2:
                  (r = e.sent),
                    (i = n.currentTarget.dataset),
                    (o = i.funname),
                    (u = i.serial),
                    r && a[o](n),
                    u &&
                      !r &&
                      ((a.data._afterLoginFunName = o),
                      (a.data._afterLoginFunName_e = n));
                case 6:
                case 'end':
                  return e.stop();
              }
          }, t);
        }),
      )();
    },
    _behavior_judgeLogin: function () {
      var n = this;
      return t(
        e().mark(function t() {
          var a;
          return e().wrap(function (e) {
            for (;;)
              switch ((e.prev = e.next)) {
                case 0:
                  if (wx.getStorageSync('accessToken')) {
                    e.next = 8;
                    break;
                  }
                  return (
                    (a = n.selectComponent('#LoginPage')),
                    wx.showToast({
                      title: '请先登录',
                      duration: 1e3,
                      icon: 'none',
                    }),
                    setTimeout(function () {
                      a._showLogin();
                    }, 300),
                    e.abrupt('return', !1)
                  );
                case 8:
                  return e.abrupt('return', !0);
                case 9:
                case 'end':
                  return e.stop();
              }
          }, t);
        }),
      )();
    },
    _afterLogin: function () {
      this.afterLogin(),
        this.data._afterLoginFunName &&
          (this[this.data._afterLoginFunName](this.data._afterLoginFunName_e),
          (this.data._afterLoginFunName = null),
          (this.data._afterLoginFunName_e = null));
    },
  },
});
